#!/bin/bash 
# Copyright (C) 2008 Rene Geers (rene.geers@gmail.com) and Bjoern Remseth (la3lma@gmail.com)
# 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
# 
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

#This script assumes the current user has sudo capabilities on the host installing

HOST=$1
if [ -z $HOST ]; then
  echo "Exiting: Host not specified"
  exit 1
fi

user=`whoami`

SUDOFILE=~/src/vmwbackup/src/sudochange.sh
SUDODEST=/tmp/sudochange.sh
if [ ! -f $SUDOFILE ]; then
  echo "Exiting: Sudoers file not found"
  exit 1
fi

echo "Installing $SUDOFILE on $HOST"
scp $SUDOFILE $user@$HOST:/tmp
ssh $user@$HOST "sudo $SUDODEST"

